<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Google AJAX Search API 实例 - 基础</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <style>
      fieldset {
        float: left;
      }
    </style>
  </head>
  
  <body>
    <fieldset>
      <legend>自定义搜索引擎结果</legend>
      <div id="content-cse">正在加载...</div>
    </fieldset>
    <fieldset>
      <legend>Google.cn 结果</legend>
      <div id="content-general">正在加载...</div>
    </fieldset>
    <script src="http://www.google.cn/jsapi"></script>
    <script>
      // 加载 AJAX Search API 版本 1, 不要默认 CSS
      google.load("search", "1");
      
      google.setOnLoadCallback(function() {
        // 创建一个 SearchControl 实例
        var cseSearch = new google.search.SearchControl();
        var generalSearch = new google.search.SearchControl();
        
        var cseWebSearch = new google.search.WebSearch();
        cseWebSearch.setSiteRestriction("013647420003915267272:-h1nfhpq4nc");
        cseSearch.setResultSetSize(google.search.Search.LARGE_RESULTSET);
        
        var generalWebSearch = new google.search.WebSearch();
        generalSearch.setResultSetSize(google.search.Search.LARGE_RESULTSET);
        
        cseSearch.addSearcher(cseWebSearch);
        generalSearch.addSearcher(generalWebSearch);
        
        var drawOptions = new google.search.DrawOptions();
        drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
        // 绘制界面元素
        cseSearch.draw(document.getElementById("content-cse"), drawOptions);
        generalSearch.draw(document.getElementById("content-general"), 
            drawOptions);

        
        // 执行初始搜索
        cseSearch.execute("8700");
        generalSearch.execute("8700");
      });
    </script>
  </body>
</html>